/*
day294
2020.6.17
*/
#include<iostream>
#include<vector>
using namespace std; 

class Solution {
public:
    vector<int> replaceElements(vector<int>& arr) {
    	int max=arr.back();
    	int tem=0; 
    	arr.back()=-1;
    	
		for(int i=arr.size()-2;i>=0;--i)
		{
			tem=arr[i];
			arr[i]=max;
			if(tem>max)
			{
				max=tem;
			}
		}
		arr.back()=-1;
		return arr;
    }
};

int main()
{
	return 0;
}
